#ifndef LINALTER_H
#define LINALTER_H

#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/proc_fs.h>
#include <linux/uaccess.h>
#include <linux/sched.h>
#include <linux/mm.h>

#define PRINTK printk

#ifndef LINALTER_SOURCE
extern pid_t tracedpid;
extern spinlock_t tracedlock;
#else
pid_t tracedpid;
spinlock_t tracedlock;
#endif

enum {
	NO_TRACED_TASK = 1,
	CANNOT_WRITE_TO,
	CANNOT_WRITE_RESULT,
	TRY_COPY_SELF,
	TASK_NOT_STOPPED,
	NO_PRIVILEGE,
	NO_MM,
	NO_VMA,
	READ_KERNEL,
	TASK_NOT_TRACED,
	LEN_TOO_LONG,
	ADDR_NOT_ALIGNED,
	NO_PA,
	CANNOT_READ_FROM,
};

int amitraced(void);

int traceme(int);

struct task_struct* tracedtask(void);

/*
 * 'from' is an address in a vma in the process 'pid'
 * 'len' is the number of bytes to copy
 * 'to' is an address in the current process
 * the length of the buffer 'to' should be not less than 'len'
 */
int copy(pid_t pid, char *from, unsigned long len, char *to);

/*
 * 'from' is an address in the current process
 * 'len' is the number of bytes to write
 * 'to' is an address in the process 'pid'
 */
int write_mem(pid_t pid, char *to, char *from, unsigned long len);

void showpid(struct task_struct *t, char *page, int *len);

#endif
